#ifndef LONGKEY_PCAGENT_MODEL_OBJECT_H_
#define LONGKEY_PCAGENT_MODEL_OBJECT_H_

#include "../base/basictypes.h"
#include "../base/utils.h"

class Model;

bool IsModelLockedByCaller(const Model* model);

class ModelObject
{
public:
	Model* model() { return interlocked_exchange_pointer(&model_, model_); }

	const Model* model() const
	{
		return interlocked_exchange_pointer(&model_, model_);
	}
private:
	// C++ root of the object model. Not owned by this instance.
	mutable Model* volatile model_;

	DISALLOW_EVIL_CONSTRUCTORS(ModelObject);
};

#endif	// LONGKEY_PCAGENT_MODEL_OBJECT_H_